package com.estar.integaration.Impl.paymentPlanimpl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.estar.integaration.Mapper.paymentPlanMapper.SupplierAccountMultipleSituationMapper;
import com.estar.integaration.Service.paymentPlanService.ISupplierAccountMultipleSituationService;
import com.estar.integaration.entity.paymentPlanEntity.SupplierAccountMultipleSituation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author YJL
 * @since 2022-03-08
 */
@Service
public class SupplierAccountMultipleSituationServiceImpl extends ServiceImpl<SupplierAccountMultipleSituationMapper, SupplierAccountMultipleSituation> implements ISupplierAccountMultipleSituationService {

  @Autowired
  SupplierAccountMultipleSituationMapper supplierAccountMultipleSituationMapper;

  @Override
  public List<SupplierAccountMultipleSituation> getSupplierAccountMultipleSituationBySupplierName(String supplierName) {
    QueryWrapper queryWrapper = new QueryWrapper();
    queryWrapper.eq("supplier_name",supplierName);
    List<SupplierAccountMultipleSituation> supplierAccountMultipleSituationList = supplierAccountMultipleSituationMapper.selectList(queryWrapper);
    return supplierAccountMultipleSituationList;
  }

  /**
   * 通过SupplierName和Type做一个删除
   * @param supplierName,type
   */
  @Override
  public void removeListBySupplierNameandType(String supplierName,String type) {
    QueryWrapper queryWrapper = new QueryWrapper();
    queryWrapper.eq("supplier_name",supplierName);
    queryWrapper.eq("if_have_inventory_number",type);
    supplierAccountMultipleSituationMapper.delete(queryWrapper);
  }

  @Override
  public List<SupplierAccountMultipleSituation> getAllSPAMS() {
    return supplierAccountMultipleSituationMapper.selectList(null);
  }


  @Override
  public SupplierAccountMultipleSituation getSPAMSwithPercentageTypebySuppName(String supplierName, String type) {
    SupplierAccountMultipleSituation supplierAccountMultipleSituation = new SupplierAccountMultipleSituation();
    QueryWrapper queryWrapper = new QueryWrapper();
    queryWrapper.eq("supplier_name",supplierName);
    queryWrapper.eq("if_have_inventory_number",type);
    supplierAccountMultipleSituation = supplierAccountMultipleSituationMapper.selectOne(queryWrapper);
    return supplierAccountMultipleSituation;
  }

  @Override
  public void deleteBySupplierName(String supplierName) {
    QueryWrapper queryWrapper = new QueryWrapper();
    queryWrapper.eq("supplier_name",supplierName);
    supplierAccountMultipleSituationMapper.delete(queryWrapper);
  }


}
